package com.antsoft.database.mybatis;


/**
 * Created by Jason on 2017/3/6.
 */
public class DbContextHolder {

//    public enum DbType{
//        MASTER,SLAVE
//    }
    
    private static final ThreadLocal<DbType> contextHolder = new ThreadLocal<DbType>();

    public static void setDbType(DbType dbType){
        if(dbType==null)throw new NullPointerException();
        contextHolder.set(dbType);
    }

    public static DbType getDbType(){
//        return contextHolder.get()==null?DbType.MASTER:contextHolder.get();
    	  return (DbType) contextHolder.get();
    }

    public static void clearDbType(){
        contextHolder.remove();
    }
    
}
